using System;
using System.Collections.Generic;
using WIT.DAQ.Core.Enums;

namespace WIT.DAQ.Core.Models;

/// <summary>
/// 采集任务
/// </summary>
public class DAQTask
{
	/// <summary>
	/// Id
	/// </summary>
	public Guid Id { get; set; }

	/// <summary>
	/// 名称
	/// </summary>
	public string Name { get; set; }

	/// <summary>
	/// 站点Id
	/// </summary>
	internal Guid StationId { get; set; }

	/// <summary>
	/// 是否参与启动
	/// </summary>
	public bool Launch { get; set; }

	/// <summary>
	/// 是否开启日志
	/// </summary>
	public bool NeedLog { get; set; }

	/// <summary>
	/// 触发方式
	/// </summary>
	internal EnumTaskTriggerMode TriggerMode { get; set; }

	/// <summary>
	/// 触发方式为Loop时的频率
	/// </summary>
	internal int? Interval { get; set; }

	/// <summary>
	/// 触发方式为SocketListen时的SocketServer设备Id
	/// </summary>
	internal Guid? SocketServerId { get; set; }

	/// <summary>
	/// 触发方式为SocketListen时的SocketServer设备
	/// </summary>
	internal Device SocketServer
	{
		get
		{
			Device result = null;
			if (SocketServerId.HasValue)
			{
				result = Common.GetDevice(SocketServerId.Value);
			}
			return result;
		}
	}

	/// <summary>
	/// 描述
	/// </summary>
	public string Desc { get; set; }

	/// <summary>
	/// 多条件触发策略 (AND/OR)
	/// </summary>
	public string MultiConditionStrategy { get; set; }

	/// <summary>
	/// 触发条件的集合
	/// </summary>
	internal List<TaskCondition> Conditions { get; set; }

	/// <summary>
	/// 命名空间
	/// </summary>
	public string Namespace { get; set; }

	/// <summary>
	/// 类名
	/// </summary>
	public string ClassName { get; set; }

	/// <summary>
	/// 执行方法
	/// </summary>
	public string MethodName { get; set; }

	/// <summary>
	/// 方法参数的集合
	/// </summary>
	internal List<TaskParam> Params { get; set; }

	/// <summary>
	/// 是否将接收到的Socket消息作为参数
	/// </summary>
	public bool SocketMsgAsParam { get; set; }

	/// <summary>
	/// Socket消息标识
	/// </summary>
	public string SocketMsgIdentifier { get; set; }

	/// <summary>
	/// 回写动作的集合
	/// </summary>
	internal List<TaskWriteback> Writebacks { get; set; }

	/// <summary>
	/// 是否向SocketServer回写消息
	/// </summary>
	public bool WritebackSocketMsg { get; set; }

	/// <summary>
	/// 向SocketServer回写内容的来源
	/// </summary>
	public string SocketMsgWritebackSource { get; set; }

	/// <summary>
	/// 向SocketServer回写的内容
	/// </summary>
	public string SocketMsgWritebackContent { get; set; }

	/// <summary>
	/// 向SocketServer回写的内容是一个字符串
	/// </summary>
	public bool SocketMsgWritebackIsString { get; set; }
}
